#ifndef PATH_OPT_PROB_H
#define PATH_OPT_PROB_H

#include "algohub_common_type.h"
#include "AlgoEvaluator.h"
#include "AlgoEvaluatorDB.h"
#include <vector>

namespace pagmo_problems
{
    class PathOptProb
    {
    public:
        // Default constructor for pagmo's internal mechanisms
        PathOptProb() = default;

        PathOptProb(algo::AlgoEvaluator* evaluator,
                    const algobase::TaskConfig* config,
                    const algobase::EvaluateL1IndexMap* weights,
                    size_t num_control_points,
                    algo::AlgoEvaluatorDB* db);

        // Pagmo UDP interface
        std::vector<double> fitness(const std::vector<double>& dv) const;
        std::pair<std::vector<double>, std::vector<double>> get_bounds() const;
        size_t get_nobj() const;

        // Helper to convert a decision vector back to a path
        algobase::Path decode(const std::vector<double>& dv) const;

        // Helper to convert a path to a decision vector
        std::vector<double> encode(const algobase::Path& path) const;
        algobase::Path mutate(const algobase::Path& path, double mutation_strength = 0.1) const;

    private:
        algo::AlgoEvaluator* m_evaluator = nullptr;
        const algobase::TaskConfig* m_config = nullptr;
        const algobase::EvaluateL1IndexMap* m_weights = nullptr;
        size_t m_num_control_points = 0;
        algo::AlgoEvaluatorDB* m_db = nullptr;
    };
}

#endif // PATH_OPT_PROB_H